package com.guoxue.action.back;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.guoxue.domain.*;
import com.guoxue.service.IBookConfigService;
import com.guoxue.service.IChapterConfigService;
import com.guoxue.service.IDistrictService;
import com.guoxue.service.IExpertReadingService;
import com.guoxue.service.IExplainConfigService;
import com.guoxue.service.IPlanConfigService;
import com.guoxue.service.IPropertyConfigService;
import com.guoxue.service.IPublishLogsService;
import com.guoxue.service.IRecordConfigService;
import com.guoxue.service.IStageConfigService;
import com.guoxue.service.IStoryConfigService;
import com.guoxue.service.IUserService;
/**
 * 对应视图跳转数据加载
 * @author young
 *
 */
@Controller
@RequestMapping("View")
public class ViewAction {
	
	@Resource
	private IRecordConfigService recordServcie;
	@Resource
	private IBookConfigService bookServcie;
	@Resource
	private IChapterConfigService chapterService;
	@Resource
	private IExpertReadingService expertService;
	@Resource
	private IExplainConfigService explainService;
	@Resource
	private IPlanConfigService planConfigService;
	@Resource
	private IPropertyConfigService propertyConfigService;
	@Resource
	private IDistrictService districtService;
	@Resource
	private IStageConfigService stageConfigService;
	@Resource
	private IStoryConfigService storyService;
	@Resource
	private IUserService userService;
	@Resource
	private IPublishLogsService publishService;
	

	@RequestMapping("/{method}/{page}")
	public ModelAndView view(HttpServletRequest req, HttpServletResponse resp, @PathVariable String method,@PathVariable String page
			, ModelMap modelMap){
		if (page.equals("book")){
		 	 List<BookConfigVo> ls = bookServcie.getBookConfigList();
		 	 modelMap.addAttribute("data", ls);
		} else if(page.equals("chapter")) {
			List<ChapterConfigVo> ls = chapterService.getChapterConfigList();
			 modelMap.addAttribute("data", ls);
		} else if(page.equals("level")) {
			List<StageConfigVo> ls = stageConfigService.getStageConfigList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("master")) {
			List<ExpertReadingVo> ls = expertService.getExpertReadingList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("mean")) {
			List<ExplainConfigVo> ls = explainService.getExplainConfigList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("plan")) {
			List<PlanConfigVo> ls = planConfigService.getPlanConfigList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("prop")) {
			List<PropertyConfigVo> ls = propertyConfigService.getPropertyConfigList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("region")) {
			List<DistrictVo> ls = districtService.getDistrictList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("story")) {
			List<StoryConfigVo> ls = storyService.getStoryConfigList();
			modelMap.addAttribute("data", ls);
		} else if(page.equals("tapes")) {
			List<RecordConfigVo> ls = recordServcie.getRecordConfigList();
			modelMap.addAttribute("data",ls);
		} else if(page.equals("member")) {
			List<UserVo> ls = userService.getUserList();
			modelMap.addAttribute("data",ls);
		} else if(page.equals("publish")) {
			List<PublishLogsVo> ls = publishService.getPublishLogs();
			modelMap.addAttribute("data",ls);
		}
		return new ModelAndView(method,modelMap);
	}
}
